const matchCount = ['一','二','三','四','五','六','七','八','九','十',]
const matchType = {
  date:'天',
  month:'月',
  year:'年'
}
export default {
  props:{
    //day month year
    type:{
      type:String,
      default:'date'
    },
    interval:{
      type:Number|String,
      default:1
    },
    rangeInterval:{
      type:Number|String,
      default:7
    },
    isHasButton:{
      type:Boolean,
      default:true
    }
  },
  watch:{
    value:{
      handler(){
        this.dateVal = this.value
      },
      immediate:true
    }
  },
  methods:{
    debounce (fn){
      let time
      return function(){
        time&&clearTimeout(time)
        time = setTimeout(()=>{
          fn()
        },200)
      }
    }
  },
  computed:{
    lastDayName(){
      return `前${matchCount[this.intervalNum-1] || this.intervalNum}${matchType[this.type]}`
    },
    currDayName(){
      return `当 ${matchType[this.type]}`
    },
    nextDayName(){
      return `后${matchCount[this.intervalNum-1] || this.intervalNum}${matchType[this.type]}`
    },
    intervalNum(){
      return Number(this.interval)
    },
    rangeIntervalNum(){
      return Number(this.rangeInterval)
    }
  }
}
